//
//  ST_TIANImageBrowser.swift
//  btvideo
//
//  Created by Jason on 2021/9/17.
//  Copyright © 2021 JarvanZhang. All rights reserved.
//

import UIKit

class ST_TIANImageBrowser: UIViewController {
    
    var urlStr:String = ""
    
    var titleStr = ""
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        self.view.backgroundColor = .white

        set_up_view()
        self.view.addSubview(cover_image_view)
        let line = UIView()
        line.backgroundColor = UIColor.init(hex: 0x999999, transparency: 0.3)
        self.view.addSubview(line)
        line.snp.makeConstraints { (make) in
            make.top.equalTo(back_btn.snp.bottom).offset(5)
            make.left.right.equalTo(self.view)
            make.height.equalTo(1)
        }
        cover_image_view.snp.makeConstraints { (make) in
            make.left.right.bottom.equalTo(self.view)
            make.top.equalTo(line.snp.bottom)
        }
        
        cover_image_view.pin_setImage(from: urlStr.url, placeholderImage: ST_SwiftConst.shared.fetch_random_place_holder_image())
        
        
    }
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        self.navigationController?.navigationBar.isHidden = true
    }
    override func viewWillDisappear(_ animated: Bool) {
        super.viewWillDisappear(animated)
        self.navigationController?.navigationBar.isHidden = true
    }
    func set_up_view(){
   
        self.view.addSubview(navi_view)
        self.view.addSubview(back_btn)
        self.view.addSubview(titleLabel)
        
        
        navi_view.snp.makeConstraints { (make ) in
            make.left.right.top.equalTo(self.view)
            
            make.height.equalTo(navigationBarHeight + statusBarHeight)
        }
        
        back_btn.snp.makeConstraints { (make ) in
            make.top.equalTo(self.view).offset(statusBarHeight)
            make.left.equalTo(self.view).offset(8)
            make.width.height.equalTo(44)
        }
        titleLabel.snp.makeConstraints { (make ) in
            make.centerY.equalTo(back_btn)
            make.centerX.equalTo(self.view)
            make.height.equalTo(25)
        }
    }
    lazy var navi_view : UIView = {
        let view = UIView()
        view.backgroundColor = .white
        return view
    }()
    lazy var back_btn:UIButton = {
        let btn = UIButton()
        
        btn.setImageForAllStates(ST_ImageUtils.imageName("返回_gray")!)
        btn.addTarget(self, action: #selector(back_action(sender: )), for: .touchUpInside)
        return btn
    }()
    @objc func back_action(sender: UIButton) {
        goback_previous_controller()
    }
    
    lazy var titleLabel:UILabel = {
        let control = UILabel()
        
        control.textColor = .black
        control.font = UIFont.systemFont(ofSize: 18)
        
        control.text = titleStr
        return control
    }()

    fileprivate lazy var cover_image_view:UIImageView = {
        let v = UIImageView()
        v.contentMode = .scaleAspectFill
        v.clipsToBounds = true
        //v.cornerRadius = 5
        return v
    }()
}
